<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set("memory_limit","20M");

require_once("track.inc.php");
require_once("database.inc.php");
require_once("ad.inc.php");

?>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>League Expansion History</TITLE>
</HEAD>
<BODY>
<LINK href="levels.css" rel="stylesheet" type="text/css">
<STYLE>
A {
	text-decoration: none;
	color: black;
}
A:hover {
	text-decoration: underline;
}

TABLE {
	border: 1px solid black;
	border-spacing: 0px;
	border-collapse: collapse;
}
</STYLE>
<?php display_ad("seasons"); ?>
<BR/><BR/>
<B>Explanation</B>: this table shows the development of the sizes of all leagues in Hattrick. The numbers shown indicate the number of league levels a certain league had in a certain global season. A zero means that the league didn't exist back then. Leagues that were biggest the earliest come at the top of the list; more technically, they are sorted by size in this season, then by size in the previous season, then by size before that... etc. Global season 1 was the first season in Sweden; local season numbers are equal to global season numbers in Sweden and in the first non-Swedish leagues that were created (in global season 11), namely:<BR/><BR/>
<LI>Argentina</LI>
<LI>Germany</LI>
<LI>Italy</LI>
<LI>France</LI>
<LI>England</LI>
<LI>USA</LI>
<LI>Mexico (still Spain, back then!)</LI>
<BR/>
Leagues created in or after global season 12 have their first season as number 1. For example, Netherlands was created in season 12; therefore, the local season was 13 during global season 24. Some countries, however, have the same local season as global season, even though they weren't created alongside with Sweden. This is the case with the first 7 non-Swedish leagues mentioned above, as well as with Sweden and Danmark. If you check the historical fixtures for the top league in each of these countries, you will see that many seasons are missing, and the first "real" season is either season 11 or season 13.<BR/><BR/>
The league that is now called Mexico was originally created as "Spain", but in the first days, most users joining there were from Mexico, so the name was changed. Nevertheless, the "Spain" that took its place, in season 13, currently has a higher combined number of active and waiting users than the first league, Sweden!<BR/><BR/>
Each league gets a unique number, or LeagueID, when it is created. These are always higher for the newer leagues. There are some gaps in the numbering here and there, so if you look at the highest ID you don't have the exact number of leagues. The ID is the number shown in square brackets after the country name.<BR/><BR/>
Also, when you compare the number of active users combined with the waiting list, you get the number of interested users in a league; if all these teams were to have a team, you can calculate how full the bottom division would be. If there are more users than available spots, this percentage is higher than 100%; similarly, if there's not enough users to fill up even the second-to-bottom division, the percentage is negative. This percentage is shown in round brackets. Very full leagues (&gt;95%) are more likely to be expanded next season and shown in red. Leagues that have plenty of room to grow, or even may have been expanded prematurely (&lt;0%) are shown in blue. If you feel like experimenting, you can watch an alternative sorting (by % filled) by clicking <A HREF="seasons.php?sortbyfill=1">&gt;here&lt;</A><BR/><BR/>
Before the league reform that took place between global seasons 28 and 29 (marked by the grey <b><R</b> column), divisions VI and below all consisted of 1024 divisions. This was changed, and the league pyramid now continues to expand the lower you get, albeit less quickly. As a result, a country with 9 division levels before the league reform would be of the same size as one with 8 levels after the league reform, and 11 pre-reform levels are equal to 9 present-day levels. This is reflected in the colors of the table below; equally-sized countries before and after the reform have the same colors. Also, pre-reform sizes with no present-day equivalents have their numbers shown in <span style="background-color: cyan">cyan</span>. Imagine, 12 divisions in the old system would be 9 and 1/4ths today!<br /><br />
If you're looking for statistics on these leagues, individually, click them to look them up in the Maptrick page.<BR/><BR/>


<?php
$dbm = connect_db("dbm");
$curseason = 33; //change this every season

$query = "SELECT leagues.*, (((activeusers + waitingusers)-newcumsize) / (numberofteams-newcumsize)) *100 AS Percentage, seasons.* FROM leagues_daily leagues, seasons, divsizes WHERE level = numberoflevels-1 AND seasons.leagueid = leagues.leagueid ORDER BY ";

if ($_GET['sortbyfill']) { $query = $query . "Percentage DESC"; } //prepend "S[n] DESC, " each season when leagues get added or expanded
else { $query = $query . "s33 DESC, s32 DESC, s31 DESC, s30 DESC, s29 DESC, s28 DESC, s27 DESC, s26 DESC, s25 DESC, s24 DESC, s23 DESC, s22 DESC, s21 DESC, s20 DESC, s19 DESC, s18 DESC, s17 DESC, s16 DESC, s15 DESC, s14 DESC, s13 DESC, s12 DESC, s11 DESC, s1 DESC"; } 

$seasons = mysql_query($query, $dbm) or die (mysql_error());
?>
<TABLE border="1">
	<TR><TD ROWSPAN="2">League [ID] (Bottom div. % Full)</TD><TD COLSPAN="<?php echo ($curseason + 1) ?>"><CENTER>Global Season</CENTER></TD></TR>
	<TR>
<?php
for ($i = 1; $i <= $curseason; $i++) {
	echo "<TD><CENTER>$i</CENTER></TD>";
	if ($i == 28) echo "<td class=\"separator\"><B>R</B></TD>";
}
echo "</TR>\n";

while ($league = mysql_fetch_array($seasons)) {
	
	echo "\t<TR><TD><A HREF=\"maptrick.php?leagueid={$league['LeagueID']}\">{$league['ShortName']}</A> [{$league['LeagueID']}] ";
	if ($league['Percentage'] > 95) {
		echo "<FONT COLOR=\"red\"><B>({$league['Percentage']}%)</B></FONT></TD>";
	} else if ($league['Percentage'] < 0) {
		echo "<FONT COLOR=\"blue\"><B>({$league['Percentage']}%)</B></FONT></TD>";
	} else {
		echo "({$league['Percentage']}%)</TD>";
	}
	for ($i = 1; $i <= $curseason; $i++) {
		echo "<TD CLASS=\"s{$league[$i+22]}";
		if ($i > 28) echo "new";
		echo "\">{$league[$i+22]}</TD>";
		if ($i == 28) echo "<TD CLASS=\"separator\">&nbsp;</TD>";
	}
	echo "</TR>\n";
}
?>
</TABLE><br/><br/>
<!-- External link (down): <A HREF=\"http://www.ione.se/content.php?article.220\">http://www.ione.se/content.php?article.220</A><BR/> -->
<?php urchin(); ?>
</BODY>
</HTML>
